// 实现这个项目的构建任务
const loadNpmTasks = require('load-grunt-tasks');
const sass = require('node-sass');
module.exports = function (grunt) {
  grunt.initConfig({
    clean: {
      dist: ['dist']
    },

    sass: {
      options: {
        implementation: sass,
        // sourceMap: false
      },
      dist: {
        files: {
          'dist/assets/styles/main.css': 'src/assets/styles/main.scss'
        }
      }
    },

    babel: {
      options: {
        presets: ['@babel/preset-env']
      },
      dist: {
        files: {
          'dist/assets/scripts/main.js': 'src/assets/scripts/main.js'
        }
      }
    },

    watch: {
      css: {
        files: 'src/**/*.scss',
        tasks: ['sass'],
      },
      js: {
        files: 'src/**/*.js',
        tasks: ['babel'],
      }
    }

  })


  loadNpmTasks(grunt)
  // grunt.loadNpmTasks('grunt-sass');

  grunt.registerTask('default', ['clean', 'sass', 'babel', 'watch']);
}
